package com.shuqi.model;

import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import android.content.Context;
import android.util.Log;

import com.shuqi.common.MyTask;
import com.shuqi.common.Urls;
import com.shuqi.model.net.HttpRequest;
import com.shuqi.model.net.UrlManager;
import com.shuqi.model.net.listener.HttpRequestListener;
import com.shuqi.model.parse.parser.ProjectDetailsParser;

/**
 * 专题详情Model
 * 
 * @author zhuchen
 * 
 */
public class ProjectDetailsModel extends ModelBase implements HttpRequestListener {
    private HttpRequest httpRequest;
    private Context context;
    /** 专题ID */
    private String topicId = "";

    public ProjectDetailsModel(Context context) {
        this.context = context;
    }

    @Override
    public void action(int actionCode, Object object) {
        fireEvent(actionCode, object);

    }

    @Override
    public List<BasicNameValuePair> setParams() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getRequestUrl() {
        // TODO Auto-generated method stub
        return Urls.getProjectDetailsUrl(topicId);
    }

    public void loadData(Object... objs) {
        this.topicId = (String) objs[0];
        this.httpRequest =
                new HttpRequest(context, UrlManager.COLUMN_DOMAIN_READ, getRequestUrl(), null, this);
        this.httpRequest.setDataParseAdapter(new ProjectDetailsParser());
        MyTask.runInBackground(httpRequest, true);

    }

    @Override
    public void onDestroy() {
        if (httpRequest != null) {
            httpRequest.abort();
        }

    }

}
